<?php
namespace App\Http\Controllers\Passenger\V2\Order;

use App\Http\Controllers\Controller;
use App\Models\Orders;
use App\Models\RefundOrder;
use App\Services\PassengerPayService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

/**
 * 退款相关相关
 * Class PayController
 * @package App\Http\Controllers\Passenger\V2\Order
 */
class RefundController extends Controller
{


    /**
     * 退款
     * @param Request $request
     */
    public function index(Request $request, PassengerPayService $service)
    {

        $order_id   = $request->post('id');
        $order_info = Orders::query()->find($order_id);

        if( !$order_info || $order_info->user_id != Auth::id())
            return $this->sendError('订单ID有误');

        $service->refund($order_info);

        return $this->sendSuccess();
    }

}
